package com.example.hzly.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import javax.persistence.*;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Data
@Entity
@Table(name = "route")
@TableName("route")
public class Route {
    @Id
    @TableId(type = IdType.AUTO)
    private Long id;

    private String title;
    private String description;
    private Integer duration;
    private BigDecimal price;
    
    @Column(name = "image_url")
    private String imageUrl;
    
    private String theme;
    private String difficulty;
    private String suitable;
    
    @Column(name = "book_count")
    private Integer bookCount;
    
    @Column(name = "is_hot")
    private Boolean isHot;
    
    @Column(name = "created_at")
    private Date createdAt;
    
    @Column(name = "updated_at")
    private Date updatedAt;
    
    @OneToMany(mappedBy = "route", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @TableField(exist = false)
    private List<RouteFeature> features;
    
    @OneToMany(mappedBy = "route", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @TableField(exist = false)
    private List<RouteItinerary> itineraries;
    
    @OneToMany(mappedBy = "route", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @TableField(exist = false)
    private List<RouteImage> gallery;
    
    @OneToMany(mappedBy = "route", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @TableField(exist = false)
    private List<RouteReview> reviews;
    
    @OneToOne(mappedBy = "route", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @TableField(exist = false)
    private RouteDetail detail;
    
    @ManyToMany
    @JoinTable(
        name = "route_destination",
        joinColumns = @JoinColumn(name = "route_id"),
        inverseJoinColumns = @JoinColumn(name = "destination_id")
    )
    @TableField(exist = false)
    private List<Destination> destinations;
}